#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e5 + 5;
const int MX = 5e4 + 5;

int n, m;
int a[N];
int b[N], num;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int x;
  while (cin >> x) a[++n] = x;
  rep(i, 1, n) {
    x = MX - a[i];
    int id = upper_bound(b + 1, b + num + 1, x) - b;
    if (id == num + 1)
      b[++num] = x;
    else
      b[id] = x;
  }
  cout << num << endl;
  num = 0;
  rep(i, 1, n) {
    x = a[i];
    // search b[id] >= x
    int id = upper_bound(b + 1, b + num + 1, x) - b;
    if (id > 1 && b[id - 1] == x) id--;
    if (id == num + 1)
      b[++num] = x;
    else
      b[id] = x;
  }
  cout << num;
  return 0;
}